package com.bw.message.controller;

import com.alibaba.nacos.api.model.v2.Result;
import com.bw.common.core.domain.R;
import com.bw.domin.Message;
import com.bw.domin.Vo.MessageHistory;
import com.bw.domin.Vo.MessageVo;
import com.bw.domin.Vo.PatientVo;
import com.bw.message.server.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
//云计算-维度健康-03-新建群发消息-张义-20250310

@RequestMapping("/patient")
@RestController
public class MessageController {
    @Autowired
    private MessageService patientService;

    /**
     * 查询所有分组及分组下的患者
     * @return
     */
    @GetMapping("/selectGroup")
    public R<List<PatientVo>> selectGroup() {
        List<PatientVo> patientVos = patientService.selectGroup();
        return R.ok(patientVos);
    }
    /**
     * 根据分组id查询患者
     */
    @GetMapping("/selectPatient/{groupId}")
    public R<List<PatientVo>> selectPatient(@PathVariable Long groupId) {
        List<PatientVo> patientVos = patientService.selectPatient(groupId);
        return R.ok(patientVos);
    }



    /**
     * 新建群发
     * @param messageVo
     */
    @PostMapping("/addMessage")
    public void addMessage(@RequestBody MessageVo messageVo) {
        patientService.addMessage(messageVo);
    }

    /**
     * 查询群发记录
     * @param messageContent
     * @return
     */
    @GetMapping("/selectMessage")
    public R<List<Message>> selectMessage(String messageContent) {
        List<Message> messageList = patientService.selectMessage(messageContent);
        return R.ok(messageList);
    }

    /**
     * 查询群发详情
     * @param id
     * @return
     */
    @GetMapping("/selectMessageDetails/{id}")
    public R<List<MessageHistory>> selectMessageDetails(@PathVariable Long id) {
        List<MessageHistory> messageHistories = patientService.selectMessageDetails(id);
        return R.ok(messageHistories);
    }

    /**
     * 查询群发历史
     * @return
     */
    @GetMapping("/selectMessageHistory")
    public R<List<MessageHistory>> selectMessageHistory() {
        List<MessageHistory> messageHistories = patientService.selectMessageHistory();
        return R.ok(messageHistories);
    }




}
